package com.ddxz.demo.liquibase.service.impl;

import com.ddxz.demo.liquibase.dto.TenantInfo;
import com.ddxz.demo.liquibase.service.LiquibaseService;
import com.ddxz.demo.liquibase.service.TenantService;
import org.postgresql.shaded.com.ongres.scram.common.util.Preconditions;
import org.springframework.stereotype.Service;

/**
 * class description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/12/17
 */

@Service
public class TenantServiceImpl implements TenantService {
    @Override
    public Object addTenant(TenantInfo tenant) {
        // 完成新租户表结构的创建
        service.updateTenant(tenant.getCode());
        // 完成新租户初始数据的添加
        service.initTenantData(tenant);

        service.saveTenant(tenant);
        return "OK";
    }

    private final LiquibaseService service;

    public TenantServiceImpl(LiquibaseService service) {
        this.service = service;
    }
}
